import requests, app


class EmployeeApi:
    def __init__(self):
        self.url_employee = app.BASE_URL + "/api/sys/user"

    def query_employee_list(self, headers):
        return requests.get(url=self.url_employee, params={"page": "1", "size": "10"}, headers=headers)

    def add_employee(self, headers, jsonData):
        return requests.post(url=self.url_employee,
                             headers=headers,
                             json=jsonData)

    def query_employee(self, headers, target):
        url_query = self.url_employee + "/" + target
        print("查询员工的URL为:", url_query)
        return requests.get(url=url_query,
                             headers=headers)

    def update_empoyee(self, headers, target, jsonData):
        url_modify = self.url_employee + "/" + target
        print("修改员工的URL为:", url_modify)
        return requests.put(url=url_modify,
                            headers=headers,
                            json=jsonData)

    def delete_employee(self,headers,target):
        url_delete = self.url_employee + "/" + target
        print("删除员工的URL为:",url_delete)
        return requests.delete(url=url_delete,headers=headers)